package day07;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class homework05 {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        ArrayList<Integer> list1 = new ArrayList<>();
        Collections.addAll(list, 1, 2, 3,4);
        Collections.addAll(list1, 3, 4, 5, 2);
        Stream<Integer> s1 = list.stream();
        Stream<Integer> s2 = list1.stream();
        Stream<Integer> s3 = Stream.concat(s1, s2);
        ArrayList<Integer> list2 = new ArrayList<>();
        s3.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()))
                .entrySet().forEach(s -> {
                    if (s.getValue() == 1) {
                        list2.add(s.getKey());
                    }
                });
        System.out.println(list2);
    }
}
